package com.shihan._02_juc_concurrent_utils._02_sync_tools.semaphore;

import java.util.concurrent.Semaphore;

/**
 * @Description Semaphore 的测试类
 * @Author shihan
 * @Date 2021/8/20 8:34
 * @Version 1.0
 */
public class MainTest {

    public static void main(String[] args) {
        // 实例化 Semaphore 信号量对象
        Semaphore semaphore = new Semaphore(2, true);

        MySemaphoreResource mySemaphoreResource = new MySemaphoreResource(semaphore);

        for (int i = 0; i < 5; i++) {
            Thread t = new Thread(mySemaphoreResource);
            t.setName("线程" + i);
            t.start();
        }
    }

}
